<?php


namespace app\common\model;


use think\Model;

class Bank extends Model
{
    /*** 获取用户所有银行卡信息
     * @param $where
     * @param $pageIndex
     * @param $pageSize
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function bankList($where,$pageIndex,$pageSize){
       return self::where($where)->order('id desc')->page($pageIndex,$pageSize)->select();
    }

    /***  获取银行卡信息
     * @param array $where
     * @return array|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function bankInfo(array $where){
        return self::where($where)->find();
    }

    /*** 获取总银行卡数
     * @param $where
     * @return int
     */
    public static function bankCount($where){
        return intval(self::where($where)->count());
    }

    /*** 银行卡信息记录
     * @param $data
     * @return Bank|Model
     */
    public static function bankAdd($data){
        return self::create($data);
    }

    /*** 银行卡信息修改
     * @param $where
     * @param $data
     * @return Bank
     */
    public static function bankEdit($where,$data){
        return self::update($data,$where);
    }
}